import request from '@/common/js/request.js'
import {channelRequestHeadFun} from '@/common/js/util'

const SERVER_URL = '/api/agent/agent/agent-web'

export default {
    // 登录
    login(data) {
        let {headData, aesData} = channelRequestHeadFun(true, data)
        return request({
            url: `${SERVER_URL}/v1/api/user/user/mini/login`,
            method: 'post',
            data: {channelRequestHead: headData, requestBody: {data: aesData}}
        })
    },
    // 更新用户信息
    updateUser(data) {
        let {headData, aesData} = channelRequestHeadFun(true, data)
        return request({
            url: `${SERVER_URL}/v1/api/user/user/mini/update`,
            method: 'post',
            data: {channelRequestHead: headData, requestBody: {data: aesData}}
        })
    },
    //获取验证码
    loginSms(data) {
        let {headData, aesData} = channelRequestHeadFun(true, data)
        return request({
            url: `${SERVER_URL}/v1/api/third-party/sms/get/smsCode`,
            method: 'post',
            data: {channelRequestHead: headData, requestBody: {data: aesData}}
        })
    },
    //获取验证码
    checkSmsCode(data) {
        let {headData, aesData} = channelRequestHeadFun(true, data)
        return request({
            url: `${SERVER_URL}/v1/api/third-party/sms/check/smsCode`,
            method: 'post',
            data: {channelRequestHead: headData, requestBody: {data: aesData}}
        })
    },
    register(data) {
        let {headData, aesData} = channelRequestHeadFun(true, data)
        return request({
            url: `${SERVER_URL}/v1/api/user/user/mini/register`,
            method: 'post',
            data: {channelRequestHead: headData, requestBody: {data: aesData}}
        })
    },


    //重置密码
    reset(data) {
        let {headData, aesData} = channelRequestHeadFun(true, data)
        return request({
            url: `${SERVER_URL}/v1/api/user/user/mini/rest/password`,
            method: 'post',
            data: {channelRequestHead: headData, requestBody: {data: aesData}}
        })
    },
    change(data) {
        let {headData, aesData} = channelRequestHeadFun(true, data)
        return request({
            url: `${SERVER_URL}/v1/api/user/change/password`,
            method: 'post',
            data: {channelRequestHead: headData, requestBody: {data: aesData}}
        })
    },
    uploadImage(data) {
        let {headData, aesData} = channelRequestHeadFun(true, data)
        return request({
            url: `${SERVER_URL}/v1/api/user/user/mini/upload/image`,
            method: 'post',
            data: {channelRequestHead: headData, requestBody: {data: aesData}}
        })
    },
}
